package com.haitonghop.controls;

import it.sephiroth.android.library.imagezoom.ImageViewTouch;

import com.haitonghop.R;
import com.haitonghop.utils.Logger;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

public class ViewPagerSupportImageView extends ViewPager {

	public ViewPagerSupportImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init();
	}

	public ViewPagerSupportImageView(Context context) {
		super(context);
		init();
	}

	@Override
	protected boolean canScroll(View v, boolean checkV, int dx, int x, int y) {
		if (v instanceof ImageViewTouch) {
			return ((ImageViewTouch) v).canScroll(dx);
		} else {
			return super.canScroll(v, checkV, dx, x, y);
		}
	}

	/**
	 * Determines whether this ImageViewTouch can be scrolled.
	 * 
	 * @param direction
	 *            - positive direction value means scroll from right to left,
	 *            negative value means scroll from left to right
	 * 
	 * @return true if there is some more place to scroll, false - otherwise.
	 */	

	private void init() {
		setOffscreenPageLimit(1);
	}

}
